package com.woniu.springbootshiro;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.servlet.MultipartConfigElement;
import javax.servlet.http.HttpServletRequest;

@SpringBootApplication
public class SpringbootShiroApplication {


  public static void main(String[] args) {
    SpringApplication.run(SpringbootShiroApplication.class, args);
  }
  @Bean
  MultipartConfigElement multipartConfigElement() {
    MultipartConfigFactory factory = new MultipartConfigFactory();
    factory.setLocation("C:/Users/EDZ/AppData/Local/Temp/tomcat-docbase.3566214387297353586.8081/img/");
    return factory.createMultipartConfig();
  }

  @Configuration
  public class FileConfig implements WebMvcConfigurer {

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
      // 文件磁盘url 映射
      // 配置server虚拟路径，handler为前台访问的目录，locations为files相对应的本地路径
      //此处将  /PlaybackData/  映射为右侧的路径
      registry.addResourceHandler("tomcat-docbase.3566214387297353586.8081/img/**").addResourceLocations("file:C:/Users/EDZ/AppData/Local/Temp/tomcat-docbase.3566214387297353586.8081/img/");//linux,注意Linux中不要有//
      //若是java:"file:E:\\\\wetemHeadUrlbProject\\FileWebsite\\PlaybackData\\"  (其中\\可以换为/)
      //http://localhost:13389/PlaybackData/434524.txt
      //映射为:/home/javauser/project1/logs/files/flydata/PlaybackData/434524.txt
    }


  }
}
